﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 策略模式
/// 1.做每一件事都 一个流程 有些步骤是固定不变的 有些步骤是根据特定的Context改变
/// 2.将不变的步骤固定 将要变的步骤设置为虚方法
/// </summary>
public class DM04Template : MonoBehaviour {

    private void Start()
    {
        IPeople personNorthern = new NorthernPeople();
        personNorthern.Dinner();
        IPeople personSouthern = new SouthernPeople();
        personSouthern.Dinner();
    } 
}

public abstract class IPeople
{
    public void Dinner()
    {
        Order();
        Eating();
        CheckBills();
    } 
    protected void Order()
    {
        Debug.Log("点单中。。");
    }
   protected  void CheckBills()
    {
        Debug.Log("买单！");
    }
   protected virtual void Eating() { }
}
public class NorthernPeople : IPeople
{
    protected  override void Eating()
    {
        Debug.Log("吃东北饺子.");
    }
}
public class SouthernPeople : IPeople
{
    protected override void Eating()
    {
        Debug.Log("吃广东烧卖");
    }
}
